package com.bwie.controller;

import com.bwie.common.domain.Menu;
import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import com.bwie.service.SysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: SysController
 * @Description: TODO
 * @version: v1.８.0
 * @author: GONGWENXUE
 * @date: 2025/10/22 9:27
 */
@CrossOrigin
@RestController
@RequestMapping("sys")
public class SysController {
    @Autowired
    SysService sysService;
    /**
     * 用户名密码登录
     */
    @GetMapping("selectNameByUser/{username}")
    public Result<User> selectNameByUser(@PathVariable("username") String username){
        User user1=sysService.selectNameByUser(username);
        return Result.success(user1);
    }
    /**
     * 手机号密码登录
     */
    @GetMapping("selectPhoneByUser/{phone}")
    public Result<User> selectPhoneByUser(@PathVariable("phone") String phone){
        User user=sysService.selectPhoneByUser(phone);
        return Result.success(user);
    }
    /**
     * 树级菜单
     */
    @GetMapping("getMenu/{userId}")
    public Result<List<Menu>> getMenu(@PathVariable("userId") Integer userId){
        List<Menu> getMenu=sysService.getMenu(userId);
        return Result.success(getMenu);
    }
}
